import { isRequired } from './utils';

/**
 * @export 数组校验
 * @param {*} { min_count, max_count } 最小 最大
 * @return {*}
 */
export function validateArrLen({ min_count, max_count }, message = '选项') {
  return {
    validator(rule, value, callback = (e) => e) {
      console.log(value, 'dadada');
      const is_length = (
        (((value.length < min_count) && min_count !== 0)
            || ((value.length > max_count) && max_count !== 0))
            && isRequired(value)
      );
      if (is_length) {
        const mesg = `最小${message}${min_count}个-最大${message}${max_count}个！`;
        callback(mesg);
        return new Error(mesg);
      }
      return true;
    }
  };
}

export function passArray() {}
